# 导入数据处理模块
import pandas as pd

# 读取csv文件
df = pd.read_csv('深圳数据分析data.csv')
# print(df.head())

# 导入配置项
from pyecharts import options as opts
# 导入饼图，柱状图，折线图，词云图
from pyecharts.charts import Pie, Bar, Line, WordCloud

# 柱状图
# 统计数据
edu_x = df['融资'].value_counts().index.tolist()
edu_y = df['融资'].value_counts().tolist()

b = (
    Bar()
    .add_xaxis(edu_x)
    .add_yaxis("融资", edu_y, stack="stack1")
    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
    .set_global_opts(title_opts=opts.TitleOpts(title="Bar-深圳数据分析招聘企业融资情况"),
                     xaxis_opts=opts.AxisOpts(interval=1))
    .render("深圳数据分析招聘企业融资情况（柱状图）.html")
)

# 饼状图
# 统计数据
x = df['经验'].value_counts().index.tolist()
y = df['经验'].value_counts().tolist()

c = (
    Pie()
    .add(
        "",
        [
            list(z)
            for z in zip(
            x,
            y,
        )
        ],
        center=["40%", "50%"],
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(title="深圳数据分析招聘经验要求分布"),
        legend_opts=opts.LegendOpts(type_="scroll", pos_left="80%", orient="vertical"),
    )
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    .render("深圳数据分析招聘经验要求分布（饼图）.html")
)
#
deu_x = df['学历'].value_counts().index.tolist()
edu_y = df['学历'].value_counts().tolist()
d = (
    Line()
    .add_xaxis(deu_x)
    .add_yaxis("学历", edu_y, is_connect_nones=True)
    .set_global_opts(title_opts=opts.TitleOpts(title="Line-深圳数据分析招聘学历要求分布"))
    .render("深圳数据分析招聘学历要求分布（折线图）.html")
)

exp_x = df['薪资'].value_counts().index.tolist()
exp_y = df['薪资'].value_counts().tolist()
exp_data = list(zip(exp_x, exp_y))  # 将两个列表exp_x，exp_y组合成一个元组列表
print(exp_data)
(
    WordCloud()
    .add(series_name="深圳数据分析岗位热门薪资水平", data_pair=exp_data, word_size_range=[15, 90])
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="深圳数据分析岗位热门薪资水平", title_textstyle_opts=opts.TextStyleOpts(font_size=23)
        ),
        tooltip_opts=opts.TooltipOpts(is_show=True),
    )
    .render("深圳数据分析岗位热门薪资水平（词云图）.html")
)
